package com.Interface.controller;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.coobird.thumbnailator.Thumbnails;

import org.apache.commons.codec.binary.Base64;


import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.Interface.entity.ClassInfo;
import com.Interface.entity.FeedBackInfo;
import com.Interface.entity.LoginLog;
import com.Interface.entity.NoticeInfo;
import com.Interface.entity.TopicInfo;
import com.Interface.entity.TopicMarkInfo;
import com.Interface.entity.UserInfo;
import com.Interface.entity.VoteUserInfo;
import com.Interface.service.ActivityInfoService;
import com.Interface.service.ClassInfoService;
import com.Interface.service.ClassMemberAddService;
import com.Interface.service.FeedBackInfoService;
import com.Interface.service.LabelInfoService;
import com.Interface.service.LoginLogService;
import com.Interface.service.MarkInfoService;
import com.Interface.service.NoticeInfoService;
import com.Interface.service.SurverInfoService;
import com.Interface.service.TopicInfoService;
import com.Interface.service.UserInfoService;
import com.Interface.service.VoteInfoService;
import com.Interface.service.VoteUserInfoService;
import com.Interface.util.CommonUtils;
import com.Interface.util.DateUtil;
import com.Interface.util.ImgHelper;
import com.Interface.util.StaticValue;
import com.fasterxml.jackson.databind.ObjectMapper;


@Controller
@RequestMapping("/interface") 
public class InterfaceController {

	
	private static Logger logger = Logger.getLogger(InterfaceController.class); 
	@Autowired
	private UserInfoService userInfoService;
	
	@Autowired
	private TopicInfoService topicInfoService;
	
	@Autowired
	private MarkInfoService markInfoService;
	
	@Autowired 
	private  ClassInfoService classInfoService;
	
	@Autowired 
	private SurverInfoService surverInfoService;
	
	@Autowired 
	private VoteInfoService voteInfoService;
	
	@Autowired 
	private ActivityInfoService activityInfoService;
	
	@Autowired 
	private LabelInfoService labelInfoService;
	
	@Autowired
	private ClassMemberAddService classMemberAddService;
	
	@Autowired
	private FeedBackInfoService feedBackInfoService;
	
	@Autowired
	private NoticeInfoService noticeInfoService;
	
	@Autowired
	private VoteUserInfoService voteUserInfoService;
	
	@Autowired
	private LoginLogService loginLogService;
	
	
	
	public String BaseDecode(String str) throws UnsupportedEncodingException {
        byte[] bt = null;
        try {
            sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();
            bt = decoder.decodeBuffer(str);
        } catch (IOException e) {
            e.printStackTrace();
        }

        return new String(bt,"UTF-8");
    }
	

	
	//账号登陆
	@RequestMapping(value = "/moaLogin")
	public String moaLogin(HttpServletRequest request,HttpServletResponse response) throws Exception{
//		request.setAttribute("login_id", "test8");
//		return "interface/moaLogin";
		//logger.info("moaLogin 消息："+data);
		
		//String jsonStr = BaseDecode(data);
		//JSONObject json = JSONObject.fromObject(jsonStr);
		//response.sendRedirect("www.baidu.com");  
		//Map<String, Object> resultMap = new HashMap<String, Object>();
		logger.info("moaLogin 发现登陆消息：+"+"aaaa");
		StringBuilder sb = new StringBuilder();  
        InputStream inputStream = null;  
        BufferedReader reader = null;  
        try {  
            inputStream = request.getInputStream();  
            reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("UTF-8")));  
            String line = "";  
            while ((line = reader.readLine()) != null) {  
                sb.append(line);  
            }  
        } catch (IOException e) {  
            e.printStackTrace();  
        } finally {  
            if (inputStream != null) {  
                try {  
                    inputStream.close();  
                } catch (IOException e) {  
                    e.printStackTrace();  
                }  
            }  
            if (reader != null) {  
                try {  
                    reader.close();  
                } catch (IOException e) {  
                    e.printStackTrace();  
                }  
            }  
        }  
        String jsonStr= sb.toString();  
        //jsonStr = "eyAidXNlciI6IFt7ImFjY291bnRJZCI6MTA2OTIsImF2YXRhclVybCI6Imh0dHA6Ly8xMTIuNS4xODYuMjEzOjE4ODAwL3Bob3Rvcy91c2VyX3Bob3RvXzUiLCJkZXB0X2NvZGUiOiIwMDEwMDEwMTYwMDEiLCJkZXB0X2lkIjoxMDY4NCwiZGVwdF9uYW1lIjoi56aP5bu656e75Yqo5Yqe5YWsL+ecgeWFrOWPuC/kv6Hmga/lronlhajnrqHnkIbpg6gv6KeE5YiS5pSv5pKR5a6kIiwiZW1haWwiOiJsaW56b25nbWluZ0Bmai5jaGluYW1vYmlsZS5jb20iLCJlbXBDb2RlIjoiIiwiaWQiOjAsImlkZW50aXR5IjoiKzF1SGhLK0RsS3M9IiwibG9naW5fbmFtZSI6IkxJTlpPTkdNSU5HIiwibW9iaWxlIjoiMTM1OTkwNjk3MzciLCJuYW1lIjoi5p6X5a6X5piOIiwibmV0d29ya0lEIjoyLCJuZXR3b3JrTmFtZSI6Iuemj+W7uuenu+WKqOWKnuWFrCIsInBpbnlpbiI6ImxpbnpvbmdtaW5nIiwic2hvcnRfcGlueWluIjoibHptIiwidXNlcl9jb2RlIjoiMDAxMDAxMDE2MDAxOjAwOCJ9IF0sICAidG9kbyI6IFsgXSwiYXBwIjpbeyJpZCI6ImZ1amlhbl9zb2NpYWxjbGFzcyIsIm5hbWUiOiLnpL7ljLrljJbnj63nu4QifV19";
        //jsonStr = "ewogICJhcHAiIDogWwogICAgewogICAgICAiaWQiIDogImZ1amlhbl9zb2NpYWxjbGFzcyIsCiAgICAgICJuYW1lIiA6ICLnpL7ljLrljJbnj63nu4QiCiAgICB9CiAgXSwKICAidG9kbyIgOiBbCiAgICB7CiAgICAgICJ0YXNrcmwiIDogIiIKICAgIH0KICBdLAogICJ1c2VyIiA6IFsKICAgIHsKICAgICAgInBpbnlpbiIgOiAid2VpemhvbmdodWEiLAogICAgICAibG9naW5fbmFtZSIgOiAiV0VJWkhPTkdIVUEiLAogICAgICAiZW1wQ29kZSIgOiAiMjQwMDAyNjEiLAogICAgICAiZGVwdF9jb2RlIiA6ICIwMDEwMDEwMTYwMDEiLAogICAgICAidXNlcl9jb2RlIiA6ICIwMDEwMDEwMTYwMDE6MDA5IiwKICAgICAgImVtYWlsIiA6ICJ3ZWl6aG9uZ2h1YUBmai5jaGluYW1vYmlsZS5jb20iLAogICAgICAiaWRlbnRpdHkiIDogInd4NEhcL3o0SExFQkl2VG1ld2sraVBnPT0iLAogICAgICAibmFtZSIgOiAi6Z+m5b+g5Y2OIiwKICAgICAgInNob3J0X3BpbnlpbiIgOiAid3poIgogICAgfQogIF0KfQ==";
        logger.info("moaLogin smg："+jsonStr);
        //jsonStr = BaseDecode(jsonStr);
        logger.info("moaLogin smg Decrypt:"+jsonStr);
	    ObjectMapper mapper = new ObjectMapper(); 
	    String login_id="";
        String name="";
        String pic = "";
        String networkName = "";
        if(jsonStr!=null &&!jsonStr.equals("")){
        	jsonStr = new String(Base64.decodeBase64(jsonStr), "UTF-8");
        	Map jsonMap=mapper.readValue(jsonStr, Map.class);
    	    if(jsonMap!=null){
    	    	List<Map<String,Object>> userListMap = (List<Map<String, Object>>) jsonMap.get("user");
    	    	if(userListMap!=null && userListMap.size()>0){
    	    		name= userListMap.get(0).get("name").toString();
        			login_id = userListMap.get(0).get("login_name").toString();
        			if(userListMap.get(0).get("avatarUrl")!=null)
        				pic = userListMap.get(0).get("avatarUrl").toString();
        			if(userListMap.get(0).get("networkName")!=null)
        				networkName= userListMap.get(0).get("networkName").toString();
    	    	}
    	    }
        }
	    
	    //login_id="10685";
        if(login_id!=null && login_id!=""){
          UserInfo info=userInfoService.selectByLoginId(login_id);
          if(info==null){
        	  info = new UserInfo();
        	  info.setLoginId(login_id);
        	  info.setName(name);
        	  info.setPic(pic);
        	  info.setRegion(networkName);
        	  info.setCreateTime(new Date());
        	  info.setUpdateTime(new Date());
        	  info.setLastLoginTime(new Date());
        	  userInfoService.insertSelective(info);
          }else{
        	  int id = info.getId();
        	  info = new UserInfo();
        	  info.setId(id);
        	  info.setLastLoginTime(new Date());
        	  userInfoService.updateByPrimaryKeySelective(info);
          }
        }else{
        	return "{code:400,msg:\"请按照正确格式上传accountId\",data:{}}";
        }
        request.setAttribute("login_id", login_id);
		return "interface/moaLogin";
	}  
	
	
/*	@RequestMapping(value = "/moaLogin")
	public String moaLogin(HttpServletRequest request,HttpServletResponse response) throws Exception{
		return "interface/moaLogin";
	}  */
	
	
	
/*	//账号登陆
	@ResponseBody
	@RequestMapping(value = "/moaLogin")
	public String moaLogin(HttpServletRequest request,HttpServletResponse response) throws Exception{
			
			//String jsonStr = BaseDecode(data);
			//JSONObject json = JSONObject.fromObject(jsonStr);
			//response.sendRedirect("http://www.baidu.com");  
			//Map<String, Object> resultMap = new HashMap<String, Object>();
		
			return "interface/moaLogin";
	}  */


	//账号登陆
	@ResponseBody
	@RequestMapping(value = "/userLogin")
	public Map userLogin(HttpServletRequest request,HttpServletResponse response) throws Exception{
		Map<String, Object> resultMap = new HashMap<String, Object>();
		Map<String, Object> data = new HashMap<String, Object>();
		String user_name_out = request.getParameter("user_name_out");
		//user_name_out = "testclass";
		UserInfo userInfo = userInfoService.selectByLoginId(user_name_out);
		if(userInfo==null){
			resultMap.put("code", 400);
			resultMap.put("msg", "查无该用户");
			resultMap.put("data", data);
			
			LoginLog record = new LoginLog();
			record.setLogname("登陆失败日志(手机端)");
			//record.setUserid(userInfo.getId());
			record.setCreatetime(new Date());
			record.setSucceed("成功");
			record.setMessage("查无该用户");
			String ipAddresses = request.getRemoteAddr();
			record.setIp(ipAddresses);
			loginLogService.insertSelective(record);
		}else{
			resultMap.put("code", 200);
			resultMap.put("msg", "登陆成功");
			data.put("is_first_login", "1");
			resultMap.put("data", data);
			HttpSession session=request.getSession();
			session.setAttribute(StaticValue.SESSION_USER_LOGIN_INFO,userInfo);
			Map<String, Object> param = new HashMap<String, Object>();
			param.put("user_id",userInfo.getId());
			param.put("integral_id", 1);
			
			userInfoService.oprIntegral(param);
			LoginLog record = new LoginLog();
			record.setLogname("登陆日志(手机端)");
			record.setUserid(userInfo.getId());
			record.setCreatetime(new Date());
			record.setSucceed("成功");
			String ipAddresses = request.getRemoteAddr();
			record.setIp(ipAddresses);
			loginLogService.insertSelective(record);
		}
		return resultMap;
    }  
	public List<Map<String, Object>> AnalysTopicList(List<TopicInfo> topicInfoList,int userId){
		Map<String, Object> param = new HashMap<String, Object>();
		List<Map<String, Object>> topicList = new ArrayList<Map<String, Object>>();
		List<Integer> topicId = new ArrayList<Integer>();
		if(topicInfoList!=null && topicInfoList.size()>0){
			Map<String, Object> topicMap = new HashMap<String, Object>();
			for(int i=0;i<topicInfoList.size();i++){
				Map<String, Object> topicInfoMap = new HashMap<String, Object>();
				topicInfoMap.put("topic_id",topicInfoList.get(i).getId());
				topicInfoMap.put("class_id",topicInfoList.get(i).getClassId());
				if(topicInfoList.get(i).getClassInfo()!=null){
					topicInfoMap.put("class_name",topicInfoList.get(i).getClassInfo().getName());
					topicInfoMap.put("class_pic",topicInfoList.get(i).getClassInfo().getPic());
				}else{
					topicInfoMap.put("class_name","");
					topicInfoMap.put("class_pic","");
				}
				topicInfoMap.put("create_user_id",topicInfoList.get(i).getUserId());
				if(topicInfoList.get(i).getUserInfo()!=null){
					topicInfoMap.put("create_user_name",topicInfoList.get(i).getUserInfo().getName());
					topicInfoMap.put("create_user_pic",topicInfoList.get(i).getUserInfo().getPic());
				}else{
					topicInfoMap.put("create_user_name","");
					topicInfoMap.put("create_user_pic","");
				}
				topicInfoMap.put("type",topicInfoList.get(i).getType());
				topicInfoMap.put("title",topicInfoList.get(i).getTitle());
				topicInfoMap.put("indroduce",topicInfoList.get(i).getIndroduce());
				List<String> picList= new ArrayList<String>();
				if(topicInfoList.get(i).getPic1()!=null &&topicInfoList.get(i).getPic1().length()>0)
					picList.add(topicInfoList.get(i).getPic1());
				if(topicInfoList.get(i).getPic2()!=null &&topicInfoList.get(i).getPic2().length()>0)
					picList.add(topicInfoList.get(i).getPic2());
				if(topicInfoList.get(i).getPic3()!=null &&topicInfoList.get(i).getPic3().length()>0)
					picList.add(topicInfoList.get(i).getPic3());
				if(topicInfoList.get(i).getPic4()!=null &&topicInfoList.get(i).getPic4().length()>0)
					picList.add(topicInfoList.get(i).getPic4());
				if(topicInfoList.get(i).getPic5()!=null &&topicInfoList.get(i).getPic5().length()>0)
					picList.add(topicInfoList.get(i).getPic5());
				if(topicInfoList.get(i).getPic6()!=null &&topicInfoList.get(i).getPic6().length()>0)
					picList.add(topicInfoList.get(i).getPic6());
				if(topicInfoList.get(i).getPic7()!=null &&topicInfoList.get(i).getPic7().length()>0)
					picList.add(topicInfoList.get(i).getPic7());
				if(topicInfoList.get(i).getPic8()!=null &&topicInfoList.get(i).getPic8().length()>0)
					picList.add(topicInfoList.get(i).getPic8());
				if(topicInfoList.get(i).getPic9()!=null &&topicInfoList.get(i).getPic9().length()>0)
					picList.add(topicInfoList.get(i).getPic9());
				topicInfoMap.put("pic_list",picList);
				topicInfoMap.put("video_url",topicInfoList.get(i).getVideoUrl());
				List<String> label_list= new ArrayList<String>();
				if(topicInfoList.get(i).getLabelInfo()!=null && topicInfoList.get(i).getLabelInfo().getName()!=null)
					label_list.add(topicInfoList.get(i).getLabelInfo().getName());
				topicInfoMap.put("label_list",label_list);
				topicInfoMap.put("read_cnt",topicInfoList.get(i).getReadCnt());
				topicInfoMap.put("comment_cnt",topicInfoList.get(i).getCommentCnt());
				topicInfoMap.put("forward_cnt",topicInfoList.get(i).getForwardCnt());
				topicInfoMap.put("thumbs_cnt",topicInfoList.get(i).getThumbsCnt());
				topicInfoMap.put("collect_cnt",topicInfoList.get(i).getCollectCnt());
				topicInfoMap.put("source",topicInfoList.get(i).getSource());
				topicInfoMap.put("join_cnt",topicInfoList.get(i).getJoinCnt());
				topicInfoMap.put("is_top",topicInfoList.get(i).getIsTop());
				//topicInfoMap.put("join_cnt",topicInfoList.get(i).getActivitiesJoinCnt());
				topicInfoMap.put("is_thumbs","1");
				topicInfoMap.put("is_forward","1");
				topicInfoMap.put("is_collect","1");
				topicInfoMap.put("cover_pic", topicInfoList.get(i).getCoverPic());
				if(topicInfoList.get(i).getCreateTime()!=null)
					topicInfoMap.put("create_time",DateUtil.getDateString(topicInfoList.get(i).getCreateTime()));
				
				topicMap.put(topicInfoList.get(i).getId().toString(), topicInfoMap);
				topicId.add(topicInfoList.get(i).getId());
				//pos_idx++;
			}
			List<Integer> topicIdList = new ArrayList<Integer>();
			for(String key : topicMap.keySet()){ 
				topicIdList.add(Integer.parseInt(key));
	        }
			List<Integer> typeList = new ArrayList<Integer>();
			typeList.add(2);
			typeList.add(4);
			typeList.add(5);
			param.clear();
			param.put("topic_id_list", topicIdList);
			param.put("type_list", typeList);
			param.put("user_id", userId);
			List<TopicMarkInfo> topicMarkInfoList=  markInfoService.selectUserMarkByTopicAndType(param);
			

			if(topicMarkInfoList!=null &&topicMarkInfoList.size()>0){
				for(int i=0;i<topicMarkInfoList.size();i++){
					if(topicMarkInfoList.get(i).getType()==2){
						((Map<String, Object>)topicMap.get(topicMarkInfoList.get(i).getTopicId().toString())).put("is_thumbs", "0");
					}else if (topicMarkInfoList.get(i).getType()==4){
						((Map<String, Object>)topicMap.get(topicMarkInfoList.get(i).getTopicId().toString())).put("is_forward", "0");
					}else if (topicMarkInfoList.get(i).getType()==5){
						((Map<String, Object>)topicMap.get(topicMarkInfoList.get(i).getTopicId().toString())).put("is_collect", "0");
					}
				}
			}
			for(int i=0;i<topicId.size();i++){
				topicList.add((Map<String, Object>) topicMap.get(topicId.get(i).toString()));
			}
			/*for(String key : topicMap.keySet()){ 
				topicList.add((Map<String, Object>) topicMap.get(key));
	        }*/
		}
		return topicList;
	}
	
	//Map<Integer, Integer> map = new HashMap<Integer, Integer>(); 
	
	Map<String,Object>  MapTostring(Map<String,Object> map){
		if(map==null)
			return null;
		for (Entry<String, Object> entry : map.entrySet()) { 
			  if(entry.getValue()==null){
				  map.put(entry.getKey(), "");
				  continue;
			  }
			  	Class<? extends Object> keyClass = entry.getValue().getClass(); 
				if(keyClass.equals(Integer.class)){
					map.put(entry.getKey(), entry.getValue().toString());
				}
			  
			}
		return map;
	}
	List<Map<String,Object>>  ListMapTostring(List<Map<String,Object>>  listMap){
		if(listMap==null)
			return null;
		for(int i=0;i< listMap.size() ;i++){
			for (Entry<String, Object> entry : listMap.get(i).entrySet()) { 
				if(entry.getValue()==null){
					listMap.get(i).put(entry.getKey(), "");
					continue;
				}
				Class<? extends Object> keyClass = entry.getValue().getClass(); 
				if(keyClass.equals(Integer.class)){
					listMap.get(i).put(entry.getKey(), entry.getValue().toString());
				}
				
			}
		}
		
		return listMap;
	}
	//主页话题预览查询
	@ResponseBody
	@RequestMapping(value = "/homepagetopicSearch")
	public Map homepagetopicSearch(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		int type = Integer.parseInt((request.getParameter("type")==null || request.getParameter("type").equals(""))?"0":request.getParameter("type"));
		int pos_idx =Integer.parseInt((request.getParameter("pos_idx")==null || request.getParameter("pos_idx").equals(""))?"0":request.getParameter("pos_idx"));
		int count = Integer.parseInt((request.getParameter("count")==null || request.getParameter("count").equals(""))?"10":request.getParameter("count"));
		Map<String, Object> param = new HashMap<String, Object>();
		if(request.getParameter("topic_type")!=null){
			param.put("topic_type", Integer.parseInt(request.getParameter("topic_type")));
		}
		param.put("type", type);
		param.put("pos_idx", pos_idx);
		param.put("count", count);
		param.put("user_id", userId);
		
		List<TopicInfo> topicInfoList =  topicInfoService.selectRecommend(param);
		Map<String, Object> resultMap = new HashMap<String, Object>();
		List<Map<String, Object>> topicList = AnalysTopicList(topicInfoList, userId);
		if(topicList!=null)
			pos_idx = pos_idx + topicList.size();
		
		if(topicList==null){
			topicList = new ArrayList<Map<String, Object>>();
		}	
		resultMap.put("data", ListMapTostring(topicList));
		resultMap.put("code", 200);
		resultMap.put("msg", "");
		resultMap.put("pos_idx", pos_idx);
		return resultMap;
    }
	//关键词搜索
	@ResponseBody
	@RequestMapping(value = "/keyWordSearch")
	public Map keyWordSearch(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		String keyWord = request.getParameter("keyWord");
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		Map<String, Object> param = new HashMap<String, Object>();
		
		int source = request.getParameter("source")==null?0:Integer.parseInt(request.getParameter("source"));
		
		param.put("keyWord", keyWord);
		param.put("pos_idx", 0);
		param.put("count", 3);
		param.put("user_id", userId);
		List<Map<String, Object>> classInfoList= classInfoService.selectByKeyWord(param);
		for(int i=0;i<classInfoList.size();i++){
			if(classInfoList.get(i).get("class_id_use")==null || classInfoList.get(i).get("class_id_use").equals("")){
				classInfoList.get(i).put("is_join_class", "1");
			}else{
				classInfoList.get(i).put("is_join_class", "0");
			}
			if(classInfoList.get(i).get("is_self")==null || classInfoList.get(i).get("is_self").equals("") || classInfoList.get(i).get("is_self").equals("1")){
				classInfoList.get(i).put("is_self", "1");
			}else{
				classInfoList.get(i).put("is_self", "0");
			}
			classInfoList.get(i).remove("class_id_use");
		}
		if(source==1)
			param.put("type", 0);
		
		
		List<TopicInfo> topicInfoList =topicInfoService.selectByKeyWord(param);
		List<Map<String, Object>> topicInfoMapList=AnalysTopicList(topicInfoList, userId);
		Map<String, Object> data = new HashMap<String, Object>();
		data.put("class_list", ListMapTostring(classInfoList));
		data.put("topic_list", ListMapTostring(topicInfoMapList));
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("code", 200);
		resultMap.put("msg", "");
		resultMap.put("data", data);
		if(source ==1){
			param.put("type", 0);
			resultMap.put("topic_cnt", topicInfoService.getCountByKeyWord(param));
			param.put("type", 1);
			resultMap.put("vote_cnt", topicInfoService.getCountByKeyWord(param));
			param.put("type", 2);
			resultMap.put("surver_cnt", topicInfoService.getCountByKeyWord(param));
			param.put("type", 3);
			resultMap.put("activities_cnt", topicInfoService.getCountByKeyWord(param));
			
			resultMap.put("class_cnt", classInfoService.getClassCountByKeyWord(param));
		}
		return resultMap;
    }  
	
	//关键词更多班组
	@ResponseBody
	@RequestMapping(value = "/keyWordSearchMoreClass")
	public Map keyWordSearchMoreClass(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		String keyWord = request.getParameter("keyWord");
		int pos_idx =Integer.parseInt((request.getParameter("pos_idx")==null || request.getParameter("pos_idx").equals(""))?"0":request.getParameter("pos_idx"));
		int count = Integer.parseInt((request.getParameter("count")==null || request.getParameter("count").equals(""))?"10":request.getParameter("count"));
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("keyWord", keyWord);
		param.put("pos_idx", pos_idx);
		param.put("count", count);
		param.put("user_id", userId);
		List<Map<String, Object>> classInfoList= classInfoService.selectByKeyWord(param);
		if(classInfoList!=null){
			for(int i=0;i<classInfoList.size();i++){
				if(classInfoList.get(i).get("class_id_use")==null || classInfoList.get(i).get("class_id_use").equals("")){
					classInfoList.get(i).put("is_join_class", "1");
				}else{
					classInfoList.get(i).put("is_join_class", "0");
				}
				if(classInfoList.get(i).get("is_self")==null || classInfoList.get(i).get("is_self").equals("") || classInfoList.get(i).get("is_self").equals("1")){
					classInfoList.get(i).put("is_self", "1");
				}else{
					classInfoList.get(i).put("is_self", "0");
				}
				classInfoList.get(i).remove("class_id_use");
				pos_idx++;
			} 
		}
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("code", 200);
		resultMap.put("msg", "");
		if(classInfoList==null){
			classInfoList = new ArrayList<Map<String, Object>>();
		}
		resultMap.put("data", ListMapTostring(classInfoList));
		resultMap.put("pos_idx", pos_idx);
		return resultMap;
    }  
	@ResponseBody
	@RequestMapping(value = "/keyWordSearchMoreTopics")
	public Map keyWordSearchMoreTopics (HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		String keyWord = request.getParameter("keyWord");
		int pos_idx =Integer.parseInt((request.getParameter("pos_idx")==null || request.getParameter("pos_idx").equals(""))?"0":request.getParameter("pos_idx"));
		int count = Integer.parseInt((request.getParameter("count")==null || request.getParameter("count").equals(""))?"10":request.getParameter("count"));
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("keyWord", keyWord);
		param.put("pos_idx", pos_idx);
		param.put("count", count);
		param.put("user_id", userId);
		param.put("type", request.getParameter("type"));

		//List<Map<String, Object>> topicInfoList=topicInfoService.selectByKeyWord(param);
		
		List<TopicInfo> topicInfoList =topicInfoService.selectByKeyWord(param);
		List<Map<String, Object>> topicInfoMapList=AnalysTopicList(topicInfoList, userId);
		if(topicInfoMapList!=null && topicInfoMapList.size()>0)
			pos_idx  = pos_idx + topicInfoMapList.size();

		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("code", 200);
		resultMap.put("msg", "");
		if(topicInfoMapList==null){
			topicInfoMapList = new ArrayList<Map<String, Object>>();
		}
		resultMap.put("data", ListMapTostring(topicInfoMapList));
		resultMap.put("pos_idx", pos_idx);
		return resultMap;
    }  
	
	

	//话题详情查询
	@ResponseBody
	@RequestMapping(value = "/topicDetailSearch")
	public Map topicDetailSearch(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int topic_id =Integer.parseInt((request.getParameter("topic_id")));
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("topic_id", topic_id);
		param.put("user_id", userId);

		Map<String, Object> topic  = topicInfoService.selectByTopicId(param);
		if(topic!=null){
			//判断用户是否为话题班组成员
			if(topic.get("class_id_use")==null || topic.get("class_id_use").equals("")){
				topic.put("is_join_class", "1");
			}else{
				topic.put("is_join_class", "0");
			}
			if(topic.get("is_self")==null || topic.get("is_self").equals("")){
				topic.put("is_self", "1");
			}else{
				topic.put("is_self", topic.get("is_self").toString());
			}
			topic.remove("class_id_use");
			
			//图片
			List<String> picList= new ArrayList<String>();
			if(topic.get("pic1")!=null &&topic.get("pic1").toString().length()>0)
				picList.add(topic.get("pic1").toString());
			if(topic.get("pic2")!=null &&topic.get("pic2").toString().length()>0)
				picList.add(topic.get("pic2").toString());
			if(topic.get("pic3")!=null &&topic.get("pic3").toString().length()>0)
				picList.add(topic.get("pic3").toString());
			if(topic.get("pic4")!=null &&topic.get("pic4").toString().length()>0)
				picList.add(topic.get("pic4").toString());
			if(topic.get("pic5")!=null &&topic.get("pic5").toString().length()>0)
				picList.add(topic.get("pic5").toString());
			if(topic.get("pic6")!=null &&topic.get("pic6").toString().length()>0)
				picList.add(topic.get("pic6").toString());
			if(topic.get("pic7")!=null &&topic.get("pic7").toString().length()>0)
				picList.add(topic.get("pic7").toString());
			if(topic.get("pic8")!=null &&topic.get("pic8").toString().length()>0)
				picList.add(topic.get("pic8").toString());
			if(topic.get("pic9")!=null &&topic.get("pic9").toString().length()>0)
				picList.add(topic.get("pic9").toString());
			topic.put("pic_list", picList);
			topic.remove("pic1");
			topic.remove("pic2");
			topic.remove("pic3");
			topic.remove("pic4");
			topic.remove("pic5");
			topic.remove("pic6");
			topic.remove("pic7");
			topic.remove("pic8");
			topic.remove("pic9");
			//标签
			List<String> label_list= new ArrayList<String>();
			if(topic.get("label_name")!=null)
				label_list.add(topic.get("label_name").toString());
			topic.put("label_list",label_list);
			topic.remove("label");
			topic.remove("label_name");
			
			if(topic.get("create_time")!=null && topic.get("create_time")!="")
				topic.put("create_time", DateUtil.getDateString((Date)topic.get("create_time")));
		
			
			//判断是否点赞转发收藏过
			List<Integer> topicIdList = new ArrayList<Integer>();
			topicIdList.add(Integer.parseInt(topic.get("topic_id").toString()));
			List<Integer> typeList = new ArrayList<Integer>();
			typeList.add(2);
			typeList.add(4);
			typeList.add(5);
			param.clear();
			param.put("topic_id_list", topicIdList);
			param.put("type_list", typeList);
			param.put("user_id", userId);
			List<TopicMarkInfo> topicMarkInfoList=  markInfoService.selectUserMarkByTopicAndType(param);
			topic.put("is_thumbs", 1);
			topic.put("is_forward", 1);
			topic.put("is_collect", 1);
			if(topicMarkInfoList!=null &&topicMarkInfoList.size()>0){
				for(int i=0;i<topicMarkInfoList.size();i++){
					if(topicMarkInfoList.get(i).getType()==2){
						topic.put("is_thumbs", 0);
					}else if (topicMarkInfoList.get(i).getType()==4){
						topic.put("is_forward", 0);
					}else if (topicMarkInfoList.get(i).getType()==5){
						topic.put("is_collect", 0);
					}
				}
			}
			if(Integer.parseInt(topic.get("type").toString())==1||Integer.parseInt(topic.get("type").toString())==2||Integer.parseInt(topic.get("type").toString())==3){
				if(topic.get("end_time")!=null){
					if(((Date)topic.get("end_time")).getTime() > (new Date()).getTime()){
						topic.put("is_overdue", "1");
						long between=(((Date)topic.get("end_time")).getTime()-(new Date()).getTime());
						between = between /1000;
						String  remaining_time="剩余";
						remaining_time = remaining_time + (between/(24*3600)) +"天" + (between%(24*3600)/3600)+"时" + (between%3600/60)+"分";
						topic.put("remaining_time", remaining_time);
					}else{
						topic.put("is_overdue", "0");
						topic.put("remaining_time", "0天0时0分");
					}
				}
			}
			if(Integer.parseInt(topic.get("type").toString())==2){//问卷调查
				
				List<Map<String, Object>> MemberSurver = new ArrayList<Map<String, Object>>();//问题列表
				Map<String, Object> question = new HashMap<String, Object>();
				List<Map<String, Object>> optionList = new ArrayList<Map<String, Object>>();//问题选项
				Map<String, Object> option = new HashMap<String, Object>();
				
				List<Map<String, Object>> surverInfoList =surverInfoService.selectByTopicId(Integer.parseInt(topic.get("topic_id").toString()));			
				int questionNo =1;
				int optionNo =1;
				if(surverInfoList!=null && surverInfoList.size()>0){
					for(int i=0;i<surverInfoList.size();i++){
						if(i==0){ //0特殊处理
							question.put("surver_id", surverInfoList.get(i).get("id")==null?"":surverInfoList.get(i).get("id").toString());
							question.put("surver_ques_no",  surverInfoList.get(i).get("surver_ques_no")==null?"":surverInfoList.get(i).get("surver_ques_no").toString());
							//question.put("surver_ques_no", questionNo);
							question.put("surver_ques_name", surverInfoList.get(i).get("surver_ques_name")==null?"":surverInfoList.get(i).get("surver_ques_name").toString());
							question.put("option_type",surverInfoList.get(i).get("option_type")==null?"":surverInfoList.get(i).get("option_type").toString());
							
							option.put("option_id",surverInfoList.get(i).get("id")==null?"":surverInfoList.get(i).get("id").toString());
							option.put("option_no", optionNo);
							optionNo++;
							option.put("option_pic", surverInfoList.get(i).get("option_pic")==null?"":surverInfoList.get(i).get("option_pic").toString());
							option.put("option_descri", surverInfoList.get(i).get("option_descri")==null?"":surverInfoList.get(i).get("option_descri").toString());
							optionList.add(option);
						}else{
							if(question.get("surver_ques_no").toString().equals(surverInfoList.get(i).get("surver_ques_no").toString())){
								option.put("option_id", surverInfoList.get(i).get("id")==null?"":surverInfoList.get(i).get("id").toString());
								option.put("option_no", optionNo);
								optionNo++;
								option.put("option_pic", surverInfoList.get(i).get("option_pic")==null?"":surverInfoList.get(i).get("option_pic").toString());
								option.put("option_descri", surverInfoList.get(i).get("option_descri")==null?"":surverInfoList.get(i).get("option_descri").toString());
								optionList.add(option);
							}else{
								question.put("vote_list", optionList);
								optionNo=1;
								questionNo++;
								optionList = new ArrayList<Map<String, Object>>();
								MemberSurver.add(question);
								question = new HashMap<String, Object>();
								question.put("surver_id", surverInfoList.get(i).get("id")==null?"":surverInfoList.get(i).get("id").toString()); 
								//question.put("surver_ques_no",questionNo );
								question.put("surver_ques_no",  surverInfoList.get(i).get("surver_ques_no")==null?"":surverInfoList.get(i).get("surver_ques_no").toString());
								question.put("surver_ques_name", surverInfoList.get(i).get("surver_ques_name")==null?"":surverInfoList.get(i).get("surver_ques_name").toString());
								question.put("option_type", surverInfoList.get(i).get("option_type")==null?"":surverInfoList.get(i).get("option_type").toString());
								
								option.put("option_id", surverInfoList.get(i).get("id")==null?"":surverInfoList.get(i).get("id").toString());
								option.put("option_no", optionNo);
								optionNo++;
								option.put("option_pic", surverInfoList.get(i).get("option_pic")==null?"":surverInfoList.get(i).get("option_pic").toString());
								option.put("option_descri", surverInfoList.get(i).get("option_descri")==null?"":surverInfoList.get(i).get("option_descri").toString());
								optionList.add(option);
							}
						}
						option = new HashMap<String, Object>();
					}
					question.put("vote_list", optionList);
					MemberSurver.add(question);
					topic.put("surver_list", MemberSurver);
					for(int i=0;i<MemberSurver.size();i++){
						MemberSurver.get(i).put("surver_ques_no", String.valueOf(i+1));
					}

					param.clear();
					param.put("topic_id", Integer.parseInt(topic.get("topic_id").toString()));
					param.put("user_id", userId);
					int count=surverInfoService.userIsJoin(param);
					if(count>0){
						topic.put("is_join_surver", "0");
					}else{
						topic.put("is_join_surver", "1");
					}
					
				}
			}else if(Integer.parseInt(topic.get("type").toString())==1){//投票
				List<Map<String, Object>> MemberVote = voteInfoService.selectByTopicId(Integer.parseInt(topic.get("topic_id").toString()));
				for(int i=0;i<MemberVote.size();i++){
					MemberVote.get(i).put("option_no",String.valueOf(i+1));
				}
				topic.put("vote_list", ListMapTostring(MemberVote));
			}else if (Integer.parseInt(topic.get("type").toString())==3){
				param.clear();
				param.put("topic_id", Integer.parseInt(topic.get("topic_id").toString()));
				param.put("user_id", userId);
				int count=activityInfoService.userIsJoin(param);
				if(count>0){
					topic.put("is_join_activity", "0");
				}else{
					topic.put("is_join_activity", "1");
				}
				
			}
			
			topicInfoService.updateTopicReadCnt(topic_id);
		}		
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("code", 200);
		resultMap.put("msg", "");
		if(topic==null)
			topic = new HashMap<String, Object>();
		resultMap.put("data", MapTostring(topic));
		return resultMap;
    } 
	
	//话题评论查询
	@ResponseBody
	@RequestMapping(value = "/commentSearch")
	public Map commentSearch(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		int topic_id =Integer.parseInt((request.getParameter("topic_id")));
		int pos_idx =Integer.parseInt((request.getParameter("pos_idx")==null || request.getParameter("pos_idx").equals(""))?"0":request.getParameter("pos_idx"));
		int count = Integer.parseInt((request.getParameter("count")==null || request.getParameter("count").equals(""))?"10":request.getParameter("count"));
		
		
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("topic_id", topic_id);
		param.put("user_id", userId);
		param.put("pos_idx", pos_idx);
		param.put("count", count);
		List<Map<String, Object>> commentList = markInfoService.selectComment(param);
		if(commentList!=null && commentList.size()>0){
			pos_idx = pos_idx + commentList.size();
		}
		if(commentList!=null){
			for(int i=0;i<commentList.size();i++){
				if(commentList.get(i).get("create_time")!=null && commentList.get(i).get("create_time")!="")
					commentList.get(i).put("create_time", DateUtil.getDateString((Date)commentList.get(i).get("create_time")));
				if(commentList.get(i).get("type").toString().equals("3")){
					commentList.get(i).put("type", "0");
				}
				
				if(commentList.get(i).get("type").toString().equals("7")){
					commentList.get(i).put("type", "1");
				}
			}
		}
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("code", 200);
		resultMap.put("msg", "");
		if(commentList==null){
			commentList = new ArrayList<Map<String, Object>>();
		}
		resultMap.put("data", ListMapTostring(commentList));
		resultMap.put("pos_idx", pos_idx);
		return resultMap;
    } 
	
	//个人话题预览查询
	@ResponseBody
	@RequestMapping(value = "/userTopicSearch")
	public Map userTopicSearch(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		int type = Integer.parseInt((request.getParameter("type")==null || request.getParameter("type").equals(""))?"0":request.getParameter("type"));
		int topic_type =Integer.parseInt((request.getParameter("topic_type")==null || request.getParameter("topic_type").equals(""))?"0":request.getParameter("topic_type"));
		int pos_idx =Integer.parseInt((request.getParameter("pos_idx")==null || request.getParameter("pos_idx").equals(""))?"0":request.getParameter("pos_idx"));
		int count = Integer.parseInt((request.getParameter("count")==null || request.getParameter("count").equals(""))?"10":request.getParameter("count"));
		if(type==0 && request.getParameter("user_id")!=null && request.getParameter("user_id")!=""){
			userId = Integer.parseInt((request.getParameter("user_id")));
		}
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("type", type);
		param.put("user_id", userId);
		param.put("topic_type", topic_type);
		param.put("pos_idx", pos_idx);
		param.put("count", count);
		
		
		List<TopicInfo> topicInfoList =null;
		if(type==0){
			topicInfoList = topicInfoService.selectUserTopicPreview(param);
		}else if (type==1 || type==2){
			topicInfoList = topicInfoService.selectUserCollectionTopicPreview(param);
		}
		Map<String, Object> resultMap = new HashMap<String, Object>();
		List<Map<String, Object>> topicList = AnalysTopicList(topicInfoList, userId);
		if(topicList!=null)
			pos_idx = pos_idx + topicList.size();
		
		if(topicList==null){
			topicList = new ArrayList<Map<String, Object>>();
		}
		resultMap.put("data", ListMapTostring(topicList));
		resultMap.put("code", 200);
		resultMap.put("msg", "");
		resultMap.put("pos_idx", pos_idx);
		return resultMap;
    } 
	
	//班组话题预览查询
	@ResponseBody
	@RequestMapping(value = "/classTopicSearch")
	public Map classTopicSearch(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		
		int topic_type =Integer.parseInt((request.getParameter("topic_type")==null || request.getParameter("topic_type").equals(""))?"0":request.getParameter("topic_type"));
		int pos_idx =Integer.parseInt((request.getParameter("pos_idx")==null || request.getParameter("pos_idx").equals(""))?"0":request.getParameter("pos_idx"));
		int count = Integer.parseInt((request.getParameter("count")==null || request.getParameter("count").equals(""))?"10":request.getParameter("count"));
		Map<String, Object> param = new HashMap<String, Object>();
		
		
		if(request.getParameter("class_id")!=null){
			int class_id = Integer.parseInt(request.getParameter("class_id"));
			param.put("class_id", class_id);
		}
		
		param.put("user_id", userId);
		param.put("topic_type", topic_type);
		param.put("pos_idx", pos_idx);
		param.put("count", count);
		List<TopicInfo> topicInfoList =  topicInfoService.selectClassTopicPreview(param);
		Map<String, Object> resultMap = new HashMap<String, Object>();
		List<Map<String, Object>> topicList = AnalysTopicList(topicInfoList, userId);
		if(topicList!=null)
			pos_idx = pos_idx + topicList.size();
		
		
		if(topicList==null){
			topicList = new ArrayList<Map<String, Object>>();
		}
		resultMap.put("data", ListMapTostring(topicList));
		resultMap.put("code", 200);
		resultMap.put("msg", "");
		resultMap.put("pos_idx", pos_idx);
		return resultMap;
    } 
	
	//用户信息查询
	@ResponseBody
	@RequestMapping(value = "/userInfo")
	public Map userInfo(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		Map<String, Object> data =userInfoService.getUserInfoById(userId);
		data.put("alert_cnt", noticeInfoService.getAlertNum(userId));
		
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("user_id",userId);
		param.put("integral_id", 2);
		data.put("is_sign", String.valueOf(userInfoService.isCanSign(param)));
		
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("code", 200);
		resultMap.put("msg", "");
		if(data==null){
			data = new HashMap<String, Object>();
		}
		resultMap.put("data", MapTostring(data));
		return resultMap;
    } 
	
	//用户评论查询
	@ResponseBody
	@RequestMapping(value = "/userCommentSearch")
	public Map userCommentSearch(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		int pos_idx =Integer.parseInt((request.getParameter("pos_idx")==null || request.getParameter("pos_idx").equals(""))?"0":request.getParameter("pos_idx"));
		int count = Integer.parseInt((request.getParameter("count")==null || request.getParameter("count").equals(""))?"10":request.getParameter("count"));
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("pos_idx", pos_idx);
		param.put("count", count);
		param.put("user_id", userId);
		List<Map<String, Object>> data=markInfoService.getUserCommentbyUserId(param);
		if(data!=null){
			for(int i=0;i<data.size();i++){
				if(data.get(i).get("create_time")!=null){
					data.get(i).put("create_time", DateUtil.getDateString((Date)data.get(i).get("create_time")));
				}
				pos_idx++;
			}
		}
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("code", 200);
		resultMap.put("pos_idx", pos_idx);
		resultMap.put("msg", "");
		if(data==null){
			data = new ArrayList<Map<String, Object>>();
		}
	    resultMap.put("data", ListMapTostring(data));
		return resultMap;
	} 
	
	//用户信息设置
	@ResponseBody
	@RequestMapping(value = "/userInfoSet")
	public Map userInfoSet(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		
		//TODO
		
		
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("code", 1);
		return resultMap;
    } 
	
	//班组字典查询
	@ResponseBody
	@RequestMapping(value = "/classSearch")
	public Map classSearch(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		//int userId = 2;
		List<Map<String, Object>> classInfoList= classInfoService.getUserJoinClassIdName(userId);
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("code", 200);
		resultMap.put("msg", "");
		if(classInfoList==null){
			classInfoList = new ArrayList<Map<String, Object>>();
		}
		resultMap.put("data", ListMapTostring(classInfoList));
		return resultMap;
    } 
	
	//标签字典查询
	@ResponseBody
	@RequestMapping(value = "/labelSearch")
	public Map labelSearch(HttpServletRequest request,HttpServletResponse response) throws Exception{
		//HttpSession session=request.getSession();
		//UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		List<Map<String, Object>> labelInfoList= labelInfoService.getLabelInfo();
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("code", 200);
		resultMap.put("msg", "");
		if(labelInfoList==null){
			labelInfoList = new ArrayList<Map<String, Object>>();
		}
		resultMap.put("data", ListMapTostring(labelInfoList));
		return resultMap;
    } 
	
	//话题操作
	@ResponseBody
	@RequestMapping(value = "/topicMarkOperate")
	public Map topicMarkOperate(HttpServletRequest request,HttpServletResponse response) throws Exception{
		Map<String, Object> resultMap = new HashMap<String, Object>();
		Map<String, Object> data = new HashMap<String, Object>();
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		//int userId=2;
		int topic_id =Integer.parseInt((request.getParameter("topic_id")));
		int type =Integer.parseInt((request.getParameter("type")));
		/*if(type==8){
			resultMap.put("code", 200);
			resultMap.put("msg", "操作成功");
			resultMap.put("data", data);
			return resultMap;
		}*/
		if(type==9){     //取消收藏
			Map<String, Object> param = new HashMap<String, Object>();
			param.put("user_id", userId);
			param.put("topic_id", topic_id);
			int delRlt = markInfoService.deleteByCollection(param);
			if(delRlt==0){
				resultMap.put("code", 400);
				resultMap.put("msg", "取消收藏失败");
				resultMap.put("data", data);
			}else{
				resultMap.put("code", 200);
				resultMap.put("msg", "取消收藏成功");
				resultMap.put("data", data);
			}
			return resultMap;
		}else if (type==10){ //取消话题点赞
			Map<String, Object> param = new HashMap<String, Object>();
			param.put("user_id", userId);
			param.put("topic_id", topic_id);
			int delRlt = markInfoService.deleteTopicThumbs(param);
			if(delRlt==0){
				resultMap.put("code", 400);
				resultMap.put("msg", "取消文章点赞失败");
				resultMap.put("data", data);
			}else{
				resultMap.put("code", 200);
				resultMap.put("msg", "取消文章点赞成功");
				resultMap.put("data", data);
			}
			return resultMap;
		}
		else if (type==11){ //取消评论点赞
			Map<String, Object> param = new HashMap<String, Object>();
			param.put("user_id", userId);
			param.put("topic_id", topic_id);
			int  topic_mark_id = Integer.parseInt((request.getParameter("topic_mark_id")));
			param.put("topic_mark_id", topic_mark_id);
			int delRlt = markInfoService.deleteCommentThumbs(param);
			if(delRlt==0){
				resultMap.put("code", 400);
				resultMap.put("msg", "取消评论点赞失败");
				resultMap.put("data", data);
			}else{
				resultMap.put("code", 200);
				resultMap.put("msg", "取消评论点赞成功");
				resultMap.put("data", data);
			}
			return resultMap;
		}
		else if (type ==12)
		{
			Map<String, Object> param = new HashMap<String, Object>();
			param.put("user_id", userId);
			param.put("topic_id", topic_id);
			int delRlt = topicInfoService.deleteTopic(param);
			if(delRlt==0){
				resultMap.put("code", 400);
				resultMap.put("msg", "删除话题失败");
				resultMap.put("data", data);
			}else{
				resultMap.put("code", 200);
				resultMap.put("msg", "删除话题成功");
				resultMap.put("data", data);
			}
			return resultMap;
		}
		
		
		if(type!=2 &&type!=3&&type!=4&&type!=5&&type!=6&&type!=7&&type!=8&&type!=9){
			resultMap.put("code", 400);
			resultMap.put("msg", "未知操作类型");
			resultMap.put("data", data);
			return resultMap;
		}
		Integer topic_mark_id = null;
		if(type==6 || type==7){
			topic_mark_id = Integer.parseInt((request.getParameter("topic_mark_id")));
		}
		String comment = request.getParameter("comment")==null?"":request.getParameter("comment");
		if((type==3 || type==7) &&  comment==""){
			resultMap.put("code", 400);
			resultMap.put("msg", "请填写内容");
			resultMap.put("data", data);
			return resultMap;
		}
		TopicMarkInfo topicMarkInfo =new TopicMarkInfo();
		topicMarkInfo.setTopicId(topic_id);
		topicMarkInfo.setType(type);
		topicMarkInfo.setTopicMarkId(topic_mark_id);
		topicMarkInfo.setComment(comment);
		topicMarkInfo.setUserId(userId);
		if(type==4){//转发
			topicMarkInfo.setClassId(Integer.parseInt(request.getParameter("class_id").toString()));
		}
		String rlt=markInfoService.topicMarkOperate(topicMarkInfo);
		if(rlt.equals("")){//成功	
			resultMap.put("code", 200);
			resultMap.put("msg", "");
			resultMap.put("data", data);
			if(type==2 || type==6){ //点赞
				Map<String, Object> param = new HashMap<String, Object>();
				param.put("user_id",userInfo.getId());
				param.put("integral_id", 6);
				userInfoService.oprIntegral(param);
			}else if (type==3){//评论
				Map<String, Object> param = new HashMap<String, Object>();
				param.put("user_id",userInfo.getId());
				param.put("integral_id", 3);
				userInfoService.oprIntegral(param);
			}else if (type==4){//转发
				Map<String, Object> param = new HashMap<String, Object>();
				param.put("user_id",userInfo.getId());
				param.put("integral_id", 4);
				userInfoService.oprIntegral(param);
			}else if (type==5){//收藏
				Map<String, Object> param = new HashMap<String, Object>();
				param.put("user_id",userInfo.getId());
				param.put("integral_id", 5);
				userInfoService.oprIntegral(param);
			}
		}else{
			resultMap.put("code", 400);
			resultMap.put("msg", rlt);
			resultMap.put("data", data);
		}
		return resultMap;
    } 
	
	//话题置顶
	@ResponseBody
	@RequestMapping(value = "/topicTop")
	public Map topicTop(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		//TODO
		
		
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("code", 1);
		return resultMap;
    } 
	
	//话题发布
	@ResponseBody
	@RequestMapping(value = "/topicPublish")
	public Map topicPublish(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		//int userId=2;
		TopicInfo topicInfo = new TopicInfo();
		topicInfo.setUserId(userId);
		topicInfo.setClassId(Integer.parseInt(request.getParameter("class_id")));
		topicInfo.setType(0);
		topicInfo.setTitle(request.getParameter("title"));
		topicInfo.setIndroduce(request.getParameter("indroduce"));
		topicInfo.setContent(request.getParameter("content"));
		topicInfo.setPic1(request.getParameter("pic1"));
		topicInfo.setPic2(request.getParameter("pic2"));
		topicInfo.setPic3(request.getParameter("pic3"));
		topicInfo.setPic4(request.getParameter("pic4"));
		topicInfo.setPic5(request.getParameter("pic5"));
		topicInfo.setPic6(request.getParameter("pic6"));
		topicInfo.setPic7(request.getParameter("pic7"));
		topicInfo.setPic8(request.getParameter("pic8"));
		topicInfo.setPic9(request.getParameter("pic9"));
		topicInfo.setCoverPic(request.getParameter("cover_pic"));
		
		topicInfo.setSource(Integer.parseInt(request.getParameter("source")));
		
		
		topicInfo.setCreateTime(new Date());
		topicInfo.setVideoUrl(request.getParameter("video_url"));
		topicInfo.setLabel(request.getParameter("label"));
		if(topicInfo.getSource()==0){
			if(topicInfo.getContent().length()>40){
				topicInfo.setIndroduce(topicInfo.getContent().substring(0,40)+"......");
			}else{
				topicInfo.setIndroduce(topicInfo.getContent());
			}
		}
		if(Integer.parseInt(request.getParameter("source")) == 0) //手机
		{
			String contentstr = request.getParameter("content");
			for(int i = 1 ; i< 10 ; i ++)
			{
				if(request.getParameter("pic"+i)!=null &&!request.getParameter("pic"+i).toString().equals("") )
				{
					contentstr += "<br><img id=\"myImage\" src=\""+request.getParameter("pic"+i)+"\" width=\"100%\"> ";
				}
			}
			topicInfo.setContent(contentstr);
		}
		int rlt=topicInfoService.insertTopic(topicInfo);
		Map<String, Object> resultMap = new HashMap<String, Object>();
		Map<String, Object> data = new HashMap<String, Object>();
		if(rlt<=0){
			resultMap.put("code", 400);
			resultMap.put("msg", "发布话题失败");
			resultMap.put("data", data);
		}
		else{
		
			resultMap.put("code", 200);
			resultMap.put("msg", "");
			resultMap.put("data", data);
		}
		return resultMap;
    } 
	//班组创建修改
	@ResponseBody
	@RequestMapping(value = "/classCreate")
	public Map classCreate(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		Map<String, Object> resultMap = new HashMap<String, Object>();
		Map<String, Object> data = new HashMap<String, Object>();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
		{
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		}
		ClassInfo classInfo =  new ClassInfo();
		classInfo.setName(request.getParameter("name"));
		classInfo.setIndroduce(request.getParameter("indroduce"));
		classInfo.setCoverPicture( request.getParameter("cover_pic"));
		classInfo.setPic(request.getParameter("pic"));
		classInfo.setCreateTime(new Date());
		classInfo.setCreateUserId(userId);
		classInfo.setMemberCnt(1);
		classInfo.setLabel(request.getParameter("label"));
		if(request.getParameter("is_join_check")!=null && !request.getParameter("is_join_check").equals(""))
			classInfo.setIsJoinCheck(Integer.parseInt(request.getParameter("is_join_check")));
		if(request.getParameter("is_topic_notice")!=null && !request.getParameter("is_topic_notice").equals(""))
			classInfo.setIsTopicNotice(Integer.parseInt(request.getParameter("is_topic_notice")));
		
		int type = Integer.parseInt((request.getParameter("type")==null || request.getParameter("type").equals(""))?"0":request.getParameter("type"));
		userInfo = userInfoService.selectById(Integer.toString(userId));
		//userInfo = userInfoService.selectByLoginId(userInfo.getLoginId());
		
		
		if(type==0){
			if(userInfo.getClassId()!=null){
				resultMap.put("code", 400);
				resultMap.put("msg", "你已经有班组，每个人只能创建一个班组");
				resultMap.put("data", data);
				return resultMap;
			}
			String msg=classInfoService.creatClass(classInfo);
			if(msg.length()==0){//成功
				resultMap.put("code", 200);
			}else{//失败
				resultMap.put("code", 400);
			}
			resultMap.put("msg", msg);
			resultMap.put("data", data);
			return resultMap;
	
		}else{
			/*int class_id= Integer.parseInt((request.getParameter("class_id")));
			if(class_id!=userInfo.getClassId()){
				resultMap.put("code", 400);
				resultMap.put("msg", "您并不是该班组创建人，无权限修改班组信息");
				resultMap.put("data", data);
				return resultMap;
			}*/
			if(userInfo.getClassId()==null){
				resultMap.put("code", 400);
				resultMap.put("msg", "您没有可以修改的班组");
				resultMap.put("data", data);
				return resultMap;
			}
			classInfo.setId(userInfo.getClassId());
			int rlt = classInfoService.updateByPrimaryKeySelective(classInfo);
			if(rlt==0){
				resultMap.put("code", 400);
				resultMap.put("msg", "修改失败");
				resultMap.put("data", data);
				return resultMap;
			}else{
				resultMap.put("code", 200);
				resultMap.put("msg", "修改成功");
				resultMap.put("data", data);
				return resultMap;
			}	
		}
    } 
	//班组信息查询
	@ResponseBody
	@RequestMapping(value = "/classInfoSearch")
	public Map classInfoSearch(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		Map<String, Object> resultMap = new HashMap<String, Object>();
		Map<String, Object> data = new HashMap<String, Object>();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		String class_id_str=request.getParameter("class_id");
		if(class_id_str==null || class_id_str==""){ //查看自己的班组
			//userInfo = userInfoService.selectByLoginId(userInfo.getLoginId());
			userInfo = userInfoService.selectById(Integer.toString(userId));
			if(userInfo.getClassId()==null){//没有班组
				resultMap.put("code", 200);
				resultMap.put("msg", "您并没有自己的班组");
				resultMap.put("data", data);
				return resultMap;
			}
			class_id_str = userInfo.getClassId().toString();
		}
		int class_id = Integer.parseInt(class_id_str);
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("user_id", userId);
		param.put("class_id", class_id);
		data = classInfoService.getClassInfobyClassId(param);
		if(data!=null){
			if(data.get("class_id_use")!=null){
				data.put("is_join_class", "0");
			}else{
				data.put("is_join_class", "1");
			}
			data.remove("class_id_use");
			if(data.get("is_self")!=null){
				data.put("is_self", data.get("is_self").toString());
			}else{
				data.put("is_self", "1");
			}
			List<String> label_list= new ArrayList<String>();
			if(data.get("label")!=null)
				label_list.add(data.get("label").toString());
			data.put("label_list",label_list);
			data.remove("label");
		}
		resultMap.put("code", 200);
		resultMap.put("msg", "");
		if(data==null)
			data = new HashMap<String, Object>();
		resultMap.put("data", MapTostring(data));
		return resultMap;
    } 
	
	//班组成员新增
	@ResponseBody
	@RequestMapping(value = "/classMemberAdd")
	public Map classMemberAdd(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		Map<String, Object> resultMap = new HashMap<String, Object>();
		Map<String, Object> data = new HashMap<String, Object>();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		Map<String, Object> param = new HashMap<String, Object>();
		int join_type = Integer.parseInt((request.getParameter("join_type")==null || request.getParameter("join_type").equals(""))?"0":request.getParameter("join_type"));
		int class_id = Integer.parseInt((request.getParameter("class_id")));
		int user_id  ;
		if(join_type==0){
			user_id = userId;
		}else{
			user_id = Integer.parseInt((request.getParameter("user_id")));
		}
		String reason  = (request.getParameter("reason"));
		param.put("join_type", join_type);
		param.put("class_id", class_id);
		param.put("user_id", user_id);
		param.put("reason", reason);
		String msg=classInfoService.addMember(param);
		if(msg.equals("0")){
			data.put("is_join", "0");
			msg = "";
		}else{
			data.put("is_join", "1");
		}
		if(msg.equals("")){
			resultMap.put("code", 200);
		}else{
			resultMap.put("code", 400);
		}
		resultMap.put("msg", msg);
		resultMap.put("data", MapTostring(data));
		return resultMap;
    } 
	
	//班组成员新增通知
	@ResponseBody
	@RequestMapping(value = "/classMemberAddNotice")
	public Map classMemberAddNotice(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		Map<String, Object> resultMap = new HashMap<String, Object>();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		List<Map<String, Object>>   noticeList= classMemberAddService.getAddMemberNotice(userId);
		resultMap.put("code", 200);
		resultMap.put("msg", "");
		if(noticeList==null){
			noticeList = new ArrayList<Map<String, Object>>();
		}
		resultMap.put("data", ListMapTostring(noticeList));
		return resultMap;
	} 
	
	
	//加入班组审核
	@ResponseBody
	@RequestMapping(value = "/classMemberAddCheck")
	public Map classMemberAddCheck(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		Map<String, Object> resultMap = new HashMap<String, Object>();
		Map<String, Object> data = new HashMap<String, Object>();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 	
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		int notice_id = Integer.parseInt((request.getParameter("notice_id")));
		int type = Integer.parseInt((request.getParameter("type"))); //0 待处理  1 同意 2 拒绝 3忽略
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("notice_id", notice_id);
		param.put("type", type);
		param.put("user_id", userId);
		String msg = classMemberAddService.classMemberAddCheck(param);
		if(msg.equals("")){
			resultMap.put("code", 200);
		}else{
			resultMap.put("code", 400);
		}
		resultMap.put("msg", msg);
		resultMap.put("data", data);
		return resultMap;
	} 
	
	//退出班组
	@ResponseBody
	@RequestMapping(value = "/classMemberDelete")
	public Map classMemberDelete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		Map<String, Object> resultMap = new HashMap<String, Object>();
		Map<String, Object> data = new HashMap<String, Object>();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 	
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
		{
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
			userInfo = userInfoService.selectById(Integer.toString(userId));
		}
		int type = Integer.parseInt((request.getParameter("type")));
		int class_id;
		int user_id;
		if(type==0){//主动退出班组
			class_id= Integer.parseInt((request.getParameter("class_id")));
			user_id = userId;
		}else if (type==1){
			user_id =  Integer.parseInt((request.getParameter("user_id")));
			class_id = userInfo.getClassId();
		}else{
			resultMap.put("code", 400);
			resultMap.put("msg", "未知操作");
			resultMap.put("data", data);
			return resultMap;
		}
		Map<String, Object> param=new HashMap<String, Object>();
		param.put("class_id", class_id);
		param.put("user_id", user_id);
		String msg = classInfoService.quitClass(param);
		if(msg.equals("")){
			resultMap.put("code", 200);
		}else{
			resultMap.put("code", 400);
		}
		resultMap.put("msg", msg);
		resultMap.put("data", data);
		return resultMap;
	} 
	
	
	
	
	//班组成员查询
	@ResponseBody
	@RequestMapping(value = "/classMemberSearch")
	public Map classMemberSearch(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int class_id= Integer.parseInt(request.getParameter("class_id"));
		List<Map<String,Object>> memberInfoList= classInfoService.getClassMemberInfo(class_id);
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("code", 200);
		resultMap.put("msg", "");
		if(memberInfoList==null){
			memberInfoList = new ArrayList<Map<String,Object>>();
		}
		resultMap.put("data", ListMapTostring(memberInfoList));
		return resultMap;
    } 
	
	//用户反馈
	@ResponseBody
	@RequestMapping(value = "/userFeedback")
	public Map userFeedback(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		FeedBackInfo feedBackInfo = new FeedBackInfo();
		feedBackInfo.setUserId(userId);
		feedBackInfo.setContent(request.getParameter("content"));
		feedBackInfo.setPic1(request.getParameter("pic1"));
		feedBackInfo.setPic2(request.getParameter("pic2"));
		feedBackInfo.setPic3(request.getParameter("pic3"));
		feedBackInfo.setPic4(request.getParameter("pic4"));
		feedBackInfo.setPic5(request.getParameter("pic5"));
		feedBackInfo.setPic6(request.getParameter("pic6"));
		feedBackInfo.setPic7(request.getParameter("pic7"));
		feedBackInfo.setPic8(request.getParameter("pic8"));
		feedBackInfo.setPic9(request.getParameter("pic9"));
		feedBackInfo.setCreateTime(new Date());
		Map<String, Object> resultMap = new HashMap<String, Object>();
		Map<String,Object> data = new HashMap<String, Object>();
		int rlt =feedBackInfoService.insertSelective(feedBackInfo);
		if(rlt==1){
			resultMap.put("code", 200);
			resultMap.put("msg", "");
		}else{
			resultMap.put("code", 400);
			resultMap.put("msg", "反馈问题失败");
		}
		resultMap.put("data", data);
		return resultMap;
    } 	
	//用户参加活动
	@ResponseBody
	@RequestMapping(value = "/joinActivity")
	public Map joinActivity(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		Map<String, Object> param = new HashMap<String, Object>();
		Map<String, Object> resultMap = new HashMap<String, Object>();
		
		int topic_id =Integer.parseInt((request.getParameter("topic_id")));
		param.put("topic_id",topic_id );
		param.put("user_id", userId);
		String rlt=activityInfoService.userJoin(param);
		if(rlt.equals("")){//成功	
			resultMap.put("code", 200);
			resultMap.put("msg", "");
			resultMap.put("data", "");
			
		}else{
			resultMap.put("code", 400);
			resultMap.put("msg", rlt);
			resultMap.put("data", "");
		}
		return resultMap;
    } 
	//用户投票
	@ResponseBody
	@RequestMapping(value = "/vote")
	public Map vote(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		
		
		Map<String, Object> param = new HashMap<String, Object>();
		Map<String, Object> resultMap = new HashMap<String, Object>();
		int topic_id =Integer.parseInt((request.getParameter("topic_id")));
		String vote = (request.getParameter("vote"));
		int is_anonymous = Integer.parseInt((request.getParameter("is_anonymous")));
		param.put("topic_id",topic_id );
		param.put("user_id", userId);
		param.put("vote", vote);
		param.put("is_anonymous", is_anonymous);
		String[] array = vote.split(",");
		int voteCnt = array.length;
		Map<String, Object> limitMap = topicInfoService.getVoteLimit(topic_id);
		VoteUserInfo record = new VoteUserInfo();
		record.setTopicId(topic_id);
		record.setUserId(userId);
		
		if(Integer.parseInt(limitMap.get("vote_sum_person").toString())!=0){
			 int curNum=voteUserInfoService.votePersonSum(record);
			 if(curNum + voteCnt >  Integer.parseInt(limitMap.get("vote_sum_person").toString())){
				 resultMap.put("code", 400);
				 resultMap.put("msg", "超过用户总投票次数["+limitMap.get("vote_sum_person").toString()+"]");
				 resultMap.put("data", "");
				 return resultMap;
			 }
		}
		if(Integer.parseInt(limitMap.get("vote_day_person").toString())!=0){
			int curNum=voteUserInfoService.votePersonDaySum(record);
			 if(curNum + voteCnt >  Integer.parseInt(limitMap.get("vote_day_person").toString())){
				 resultMap.put("code", 400);
				 resultMap.put("msg", "超过当天总投票次数["+limitMap.get("vote_day_person").toString()+"]");
				 resultMap.put("data", "");
				 return resultMap;
			 }
		}
		if(Integer.parseInt(limitMap.get("vote_option").toString())!=0){
			List<Map<String, Object>> optionNumMapList = voteUserInfoService.voteOptionSum(record);
			Map<String, Object>  optionNumMap = new HashMap<String, Object>();
			for(int i=0;i<optionNumMapList.size();i++){
				optionNumMap.put(optionNumMapList.get(i).get("option_no").toString(), optionNumMapList.get(i).get("cnt"));
			}
			
			
			
			for (String str : array){
				if(optionNumMap.containsKey(str)){
					int curNum = Integer.parseInt(optionNumMap.get(str).toString());
					if(curNum+voteCnt > Integer.parseInt(limitMap.get("vote_option").toString())){
						 resultMap.put("code", 400);
						 resultMap.put("msg", "超过选项最大投票次数["+limitMap.get("vote_option").toString()+"]");
						 resultMap.put("data", "");
						 return resultMap;
					}
				}else{
					if(voteCnt > Integer.parseInt(limitMap.get("vote_option").toString())){
						 resultMap.put("code", 400);
						 resultMap.put("msg", "超过选项最大投票次数["+limitMap.get("vote_option").toString()+"]");
						 resultMap.put("data", "");
						 return resultMap;
					}
				}
			}
		}

		String rlt=voteUserInfoService.userVote(param);
		if(rlt.equals("")){//成功	
			resultMap.put("code", 200);
			resultMap.put("msg", "");
			resultMap.put("data", "");
			
		}else{
			resultMap.put("code", 400);
			resultMap.put("msg", rlt);
			resultMap.put("data", "");
		}
		return resultMap;
    } 
	
	//用户调研
	@ResponseBody
	@RequestMapping(value = "/surver")
	public Map surver(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		 
		
		Map<String, Object> param = new HashMap<String, Object>();
		Map<String, Object> resultMap = new HashMap<String, Object>();
		int topic_id =Integer.parseInt((request.getParameter("topic_id")));
		String surver = (request.getParameter("surver"));
		param.put("topic_id",topic_id );
		param.put("user_id", userId);
		param.put("surver", surver);
		String rlt=surverInfoService.userSurver(param);
		if(rlt.equals("")){//成功	
			resultMap.put("code", 200);
			resultMap.put("msg", "");
			resultMap.put("data", "");
			
		}else{
			resultMap.put("code", 400);
			resultMap.put("msg", rlt);
			resultMap.put("data", "");
		}
		return resultMap;
    } 
	/**
	 * 图片上传
	 * 
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	 @ResponseBody
	 @RequestMapping(value = "/fileUpload", produces = MediaType.APPLICATION_JSON_VALUE)
	public Map FileUpload(HttpServletRequest request, HttpServletResponse response) throws Exception {
		Map<String ,Object> map = new HashMap<String ,Object>();
		int  s=request.getServletContext().getRealPath("/").lastIndexOf("webapps");
        String path=request.getServletContext().getRealPath("/").substring(0, s)+"/webapps/"+StaticValue.PROJECT_NAME;
        
        String photo=request.getParameter("picture");
        if(photo==null||photo.length()==0){
        	map.put("code", 400);
			map.put("msg", "图片不能为空");
			return map;
        }
        String suffix =request.getParameter("suffix");
        if(suffix==null||suffix.length()==0){
        	map.put("code", 400);
			map.put("msg", "图片后缀不能为空");
			return map;
        }
        //处理带有前缀的问题  去掉前缀
        String[] photo_str=photo.split(",");
        if(photo_str.length>1){
        	photo=	photo_str[1];
        }else{
        	photo=photo_str[0];
        }       
        //

		String imgName = "photo_" + CommonUtils.getFormatDate(new Date(), "yyyyMMddhhmmss")+"."+suffix; // 生成文件名
		Calendar c=Calendar.getInstance();
		int year=c.get(Calendar.YEAR);
		int month=c.get(Calendar.MONTH)+1;
		int day=c.get(Calendar.DAY_OF_MONTH);
		StringBuilder directory=new StringBuilder("");
		directory.append("/").append(year).append("/").append(month).append("/").append(day);
		File f=new File(path+directory.toString());
		if(!f.exists()) f.mkdirs();
		
		
		if(ImgHelper.GenerateImage(photo,path+directory + "/" + imgName)){
			String width=request.getParameter("width");
			String height=request.getParameter("height");
			if((width!=null&&!width.isEmpty())&&(height!=null&&!height.isEmpty())){
				Thumbnails.of(path+directory + "/" + imgName).size(Integer.parseInt(width),Integer.parseInt(height)).keepAspectRatio(false).toFile(path+directory + "/" + imgName);
			}			 
			map.put("code", 200);
			map.put("msg", "操作成功");
			Map<String ,Object> m=new HashMap<String ,Object>();
			String IP_PORT="";
			try {
				IP_PORT=PropertiesLoaderUtils.loadAllProperties("config.properties").getProperty("ip_port");
			} catch (IOException e) {
				e.printStackTrace();
			}
			m.put("url", IP_PORT+StaticValue.PROJECT_NAME+directory.toString()+ "/"+imgName);
			map.put("data", m);
		}else{
			map.put("code", 400);
			map.put("msg", "上传失败");
		}
		return map;
	}
	 
	 
		//用户班组预览查询
		@ResponseBody
		@RequestMapping(value = "/classList")
		public Map classList(HttpServletRequest request,HttpServletResponse response) throws Exception{
			HttpSession session=request.getSession();
			UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
			int userId = userInfo == null ?  0:userInfo.getId() ;
			int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
			if(nosession == 1)
				userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
			int type =Integer.parseInt((request.getParameter("type")==null || request.getParameter("type").equals(""))?"0":request.getParameter("type"));
			int pos_idx =Integer.parseInt((request.getParameter("pos_idx")==null || request.getParameter("pos_idx").equals(""))?"0":request.getParameter("pos_idx"));
			int count = Integer.parseInt((request.getParameter("count")==null || request.getParameter("count").equals(""))?"10":request.getParameter("count"));
			Map<String, Object> param = new HashMap<String, Object>();
			param.put("type", type);
			param.put("user_id",userId);
			param.put("pos_idx", pos_idx);
			param.put("count", count);   
			List<Map<String, Object>> classInfoList=classInfoService.selectClassPreview(param);
			if(classInfoList!=null && classInfoList.size()>0){
				pos_idx = pos_idx + classInfoList.size();
				for(int i=0;i<classInfoList.size();i++){
					if(classInfoList.get(i).get("class_id_use")==null || classInfoList.get(i).get("class_id_use").equals("")){
						classInfoList.get(i).put("is_join_class", "1");
					}else{
						classInfoList.get(i).put("is_join_class", "0");
					}
					if(classInfoList.get(i).get("is_self")==null || classInfoList.get(i).get("is_self").equals("") ){
						classInfoList.get(i).put("is_self", "1");
					}else{
						classInfoList.get(i).put("is_self", classInfoList.get(i).get("is_self").toString());
					}
					classInfoList.get(i).remove("class_id_use");
				}
			}
			if(request.getParameter("source")!=null){
				int source = Integer.parseInt(request.getParameter("source").toString());
				if(source==1){
					if(classInfoList!=null && classInfoList.size()>0){
						for(int i=0;i<classInfoList.size();i++){
							List<Map<String, Object>> classhotTopic=classInfoService.classhotTopic(Integer.parseInt(classInfoList.get(i).get("class_id").toString()));
							classInfoList.get(i).put("topic_list", classhotTopic);
						}
					}
				}
			}

			Map<String, Object> resultMap = new HashMap<String, Object>();
			resultMap.put("code", 200);
			resultMap.put("msg", "操作成功");
			resultMap.put("pos_idx", pos_idx);
			if(classInfoList==null){
				classInfoList = new ArrayList<Map<String, Object>>();
			}
			resultMap.put("data", ListMapTostring(classInfoList));
			return resultMap;
	    } 
	 
	 //用户签到
	@ResponseBody
	@RequestMapping(value = "/userOperate")
	public Map userOperate(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		int opetype = Integer.parseInt((request.getParameter("type")==null || request.getParameter("type").equals(""))?"1":request.getParameter("type"));
		int code = 200;
		String msg = "";
		if(opetype == 1)
		{
			
			Map<String, Object> param = new HashMap<String, Object>();
			param.put("user_id",userId);
			param.put("integral_id", 2);
			Map<String, Object> data =userInfoService.getUserInfoById(userId);
			if(data==null){
				code = 400;
				msg = "没有该用户";
			}	
			else if( userInfoService.isCanSign(param) == 0)
			{
				code = 400;
				msg = "今天已签到";
			}	
			else
			{
				userInfoService.updateSign(userId);
				//新增积分
				param = new HashMap<String, Object>();
				param.put("user_id",userId);
				param.put("integral_id", 2);
				userInfoService.oprIntegral(param);
			}
		}
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("code", code);
		resultMap.put("msg", msg);
		Map<String, Object> data = new HashMap<String, Object>();
		resultMap.put("data", MapTostring(data));
		return resultMap;
    } 

	//获取用户积分列表

	@ResponseBody
	@RequestMapping(value = "/getIntegralList")
	public Map getIntegralList(HttpServletRequest request,HttpServletResponse response) throws Exception{
		HttpSession session=request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
		int userId = userInfo == null ?  0:userInfo.getId() ;
		int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
		if(nosession == 1)
			userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
		int pos_idx =Integer.parseInt((request.getParameter("pos_idx")==null || request.getParameter("pos_idx").equals(""))?"0":request.getParameter("pos_idx"));
		int count = Integer.parseInt((request.getParameter("count")==null || request.getParameter("count").equals(""))?"10":request.getParameter("count"));
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("user_id",userId);
		param.put("pos_idx", pos_idx);
		param.put("count", count);   
		
		List<Map<String,Object>> integralList= userInfoService.selectIntegral(param);
		if(integralList!=null && integralList.size()>0)
			pos_idx = pos_idx + integralList.size();
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("code", 200);
		resultMap.put("msg", "");
		resultMap.put("pos_idx", pos_idx);
		if(integralList==null){
			integralList = new ArrayList<Map<String,Object>>();
		}
		resultMap.put("data", ListMapTostring(integralList));
		return resultMap;
    } 
	
	
	//获取用户通知列表

		@ResponseBody
		@RequestMapping(value = "/getNoticeList")
		public Map getNoticeList(HttpServletRequest request,HttpServletResponse response) throws Exception{
			HttpSession session=request.getSession();
			UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
			int userId = userInfo == null ?  0:userInfo.getId() ;
			int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
			if(nosession == 1)
				userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
			
			int pos_idx =Integer.parseInt((request.getParameter("pos_idx")==null || request.getParameter("pos_idx").equals(""))?"0":request.getParameter("pos_idx"));
			int count = Integer.parseInt((request.getParameter("count")==null || request.getParameter("count").equals(""))?"10":request.getParameter("count"));
			Map<String, Object> param = new HashMap<String, Object>();
			param.put("user_id",userId);
			param.put("pos_idx",pos_idx);
			param.put("count",count);
			List<Map<String,Object>> noticeList= noticeInfoService.selectUserNotice(param);
			noticeInfoService.updateHasGetNoticeInfo(param);
			/*noticeInfoService.updateHasGetNoticeInfo(param);*/
			Map<String, Object> resultMap = new HashMap<String, Object>();
			resultMap.put("code", 200);
			resultMap.put("msg", "");
			if(noticeList==null){
				noticeList = new ArrayList<Map<String,Object>>();
			}else{
				pos_idx = pos_idx + noticeList.size();
			}
			resultMap.put("pos_idx", pos_idx);
			resultMap.put("data", ListMapTostring(noticeList));
			return resultMap;
	    } 
		
		//获取用户通知列表

		@ResponseBody
		@RequestMapping(value = "/hotActivity")
		public Map hotActivity(HttpServletRequest request,HttpServletResponse response) throws Exception{
			HttpSession session=request.getSession();
			UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
			int userId = userInfo == null ?  0:userInfo.getId() ;
			int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
			if(nosession == 1)
				userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
			int type = Integer.parseInt((request.getParameter("type")==null || request.getParameter("type").equals(""))?"0":request.getParameter("type"));
			int pos_idx =Integer.parseInt((request.getParameter("pos_idx")==null || request.getParameter("pos_idx").equals(""))?"0":request.getParameter("pos_idx"));
			int count = Integer.parseInt((request.getParameter("count")==null || request.getParameter("count").equals(""))?"10":request.getParameter("count"));		
			Map<String, Object> param = new HashMap<String, Object>();
			param.put("user_id",userId);
			param.put("type", type);
			param.put("pos_idx", pos_idx);
			param.put("count", count);
			
			
			List<TopicInfo> topicInfoList = topicInfoService.getHotActivity(param);
			Map<String, Object> resultMap = new HashMap<String, Object>();
			List<Map<String, Object>> topicList = AnalysTopicList(topicInfoList, userId);
			if(topicList!=null)
				pos_idx = pos_idx + topicList.size();
			
			if(topicList==null){
				topicList = new ArrayList<Map<String, Object>>();
			}	
			resultMap.put("data", ListMapTostring(topicList));
			resultMap.put("code", 200);
			resultMap.put("msg", "");
			resultMap.put("pos_idx", pos_idx);
			
			
			/*
			List<Map<String,Object>> topicList= topicInfoService.getHotActivity(param);
			Map<String, Object> resultMap = new HashMap<String, Object>();
			resultMap.put("code", 200);
			resultMap.put("msg", "");
			if(topicList==null){
				topicList = new ArrayList<Map<String,Object>>();
			}
			resultMap.put("data", ListMapTostring(topicList));*/
			return resultMap;
	    } 
		
		//用户信息更改

		@ResponseBody
		@RequestMapping(value = "/alterUserInfo")
		public Map alterUserInfo(HttpServletRequest request,HttpServletResponse response) throws Exception{
			HttpSession session=request.getSession();
			UserInfo userInfo = (UserInfo) session.getAttribute(StaticValue.SESSION_USER_LOGIN_INFO); 
			int userId = userInfo == null ?  0:userInfo.getId() ;
			int nosession =Integer.parseInt((request.getParameter("no_session")==null || request.getParameter("no_session").equals(""))?"0":request.getParameter("no_session"));
			if(nosession == 1)
				userId = Integer.parseInt((request.getParameter("self_user_id")==null || request.getParameter("self_user_id").equals(""))?"0":request.getParameter("self_user_id"));
			
			UserInfo info = new UserInfo();
			info.setId(userId);
			if(request.getParameter("name")!=null)
				info.setName(request.getParameter("name"));
			if(request.getParameter("pic")!=null)
				info.setPic(request.getParameter("pic"));
			if(request.getParameter("cover_pic")!=null)
				info.setCoverPic(request.getParameter("cover_pic"));
			if(request.getParameter("leave_word")!=null)
				info.setLeaveWord(request.getParameter("leave_word"));
			if(request.getParameter("age")!=null)
				info.setAge(Integer.parseInt(request.getParameter("age")));
			if(request.getParameter("region")!=null)
				info.setRegion(request.getParameter("region"));
			
			
			Map<String, Object> resultMap = new HashMap<String, Object>();
			if(userInfoService.updateByPrimaryKeySelective(info)==1){
				resultMap.put("code", 200);
				resultMap.put("msg", "");
			}else{
				resultMap.put("code", 400);
				resultMap.put("msg", "修改失败");
			}
			return resultMap;
	    } 
}
